//
//  HMOrderModel.m
//  G05爱鲜蜂
//
//  Created by 小灰灰 on 16/10/20.
//  Copyright © 2016年 何源. All rights reserved.
//

#import "HMOrderModel.h"
#import "NetWorkTool.h"
@implementation HMOrderModel
- (void)setOrder_goods:(NSArray *)order_goods{
    
    NSMutableArray *nmArray = [NSMutableArray array];
    for (NSArray *array in order_goods) {
        HMOrderGoods *goods = [[HMOrderGoods alloc]init];
        [goods setValuesForKeysWithDictionary:array[0]];
        [nmArray addObject:goods];
    }
    _order_goods = nmArray;
}
- (void)setStatus_timeline:(NSArray<HMOrderTimeLine *> *)status_timeline{
    NSMutableArray *nmArray = [NSMutableArray array];
    for (NSDictionary *dict in status_timeline) {
        HMOrderTimeLine *goods = [[HMOrderTimeLine alloc]init];
        [goods setValuesForKeysWithDictionary:dict];
        [nmArray addObject:goods];
    }
    _status_timeline = nmArray;
}

+ (void)getDataWithsuccessBlock:(void(^)(NSArray *array))successBlock{
    [[NetWorkTool shareManager]POST_RequestWithUrlString:@"http://iosapi.itcast.cn/loveBeen/MyOrders.json.php" parmas:@{@"call":@13} successBloock:^(id responseObject) {
        
        NSDictionary *dict = responseObject;
        NSArray *dataArray = dict[@"data"];
        NSMutableArray *nmArray = [NSMutableArray array];
        for (NSDictionary *dict in dataArray) {
            HMOrderModel *orderModel = [[HMOrderModel alloc]init];
            [orderModel yy_modelSetWithDictionary:dict];
            [nmArray addObject:orderModel];
        }
        successBlock(nmArray.copy);
        
    } failureBlock:^(NSError *error) {
        NSLog(@"获取数据失败");
    }];
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key{}

@end
